
package com.rabincorp.facepoll.domain.services.poll.impl;

import com.rabincorp.facepoll.application.FacepollConstant;
import com.rabincorp.facepoll.domain.entity.poll.Poll;
import com.rabincorp.facepoll.domain.services.poll.PollDAO;
import com.rabincorp.facepoll.domain.services.poll.PollService;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 * @author isakrabin
 */

@Service
@Transactional
public class PollServiceImpl implements PollService{

    @Autowired
    private PollDAO pollDAO;

    
    @Override
    public Poll create(String title, String question, List<String> options, Boolean active, FacepollConstant.PollType type, Date startDate, Date endDate, Long ownerId) {

        
        Poll poll = new Poll(title, question, options, ownerId);
        poll.setActive(active);
        poll.setType(type);
        poll.setStartDate(startDate);
        poll.setEndDate(endDate);
        
        pollDAO.save(poll);
        
        return poll;
    }


    
}
